主题
备份注册表到文件 - RegistryBackupToFile
函数简介
备份注册表键到.reg格式文件。
接口名称
RegistryBackupToFileDLL调用
cpp
int32_t RegistryBackupToFile(int64_t instance, int32_t rootKey, const char* subKey, const char* filePath);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| rootKey | 整数型 | 根键类型:0 HKEY_CLASSES_ROOT、1 HKEY_CURRENT_USER、2 HKEY_LOCAL_MACHINE、3 HKEY_USERS、4 HKEY_CURRENT_CONFIG。 |
| subKey | 字符串 | 子键路径。 |
| filePath | 字符串 | 备份文件路径(.reg格式)。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int ret = ola.RegistryBackupToFile(1, "Software\\OLAPlug", "backup/olaplug.reg");csharp
using OLAPlug;
var ola = new OLAPlugServer();
int ret = ola.RegistryBackupToFile(1, @"Software\OLAPlug", "backup/olaplug.reg");python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
ret = ola.RegistryBackupToFile(1, r"Software\OLAPlug", "backup/olaplug.reg")java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
int ret = ola.RegistryBackupToFile(1, "Software\\OLAPlug", "backup/olaplug.reg");go
import "github.com/ola/olaplug/olaplug"
ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
ret := ola.RegistryBackupToFile(1, "Software\\OLAPlug", "backup/olaplug.reg")rust
use olaplug::OLAPlugServer;
let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let ret = ola.registry_backup_to_file(1, "Software\\OLAPlug", "backup/olaplug.reg");cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.RegistryBackupToFile(1, "Software\\OLAPlug", "backup/olaplug.reg")vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.RegistryBackupToFile(1, "Software\OLAPlug", "backup/olaplug.reg")text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.RegistryBackupToFile (1, “Software\\OLAPlug“, "backup/olaplug.reg")aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.RegistryBackupToFile(1, "Software\\OLAPlug", "backup/olaplug.reg");text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.RegistryBackupToFile(1, "Software\\OLAPlug", "backup/olaplug.reg")cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int32_t ret = ola.RegistryBackupToFile(1, "Software\\OLAPlug", "backup/olaplug.reg");原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
RegistryBackupToFile(instance, 1, "Software\\OLAPlug", "backup/olaplug.reg");csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
RegistryBackupToFile(instance, 1, @"Software\OLAPlug", "backup/olaplug.reg");python
from ctypes import CDLL, c_int, c_int64
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ola.RegistryBackupToFile(instance, 1, b"Software\\OLAPlug", b"backup/olaplug.reg")返回值
| 返回值 | 说明 |
|---|---|
1 | 成功。 |
0 | 失败。 |
注意事项
| 项目 | 说明 |
|---|---|
| 格式 | 文件将以标准.reg格式保存,可以使用regedit导入。 |
| 备份文件包含指定键及其所有子键和值 | 备份文件包含指定键及其所有子键和值。 |
| 管理员权限 | 备份系统级键可能需要管理员权限。 |
| 路径 | 确保目标文件路径可写。 |
| 格式 | 文件编码为UTF-16 LE(Windows标准.reg格式)。 |
